package cn.usain.mapper;

import cn.jiyun.pojo.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface StatisticsMapper {
/*    List<Orders> getOrdersByCondition(String cityLevel, String city, String district, String orderTime, String startTime, String endTime, String orderType);

    List<Orders> getOrdersForResponseRate(String startTime, String endTime, String orderType);*/

    // 获取所有订单，用于计算响应率
//    int countTotalOrders();
//
//    // 获取司机已接单的订单数量
//    int countRespondedOrders();
//   List<Orders> getOrdersByCondition(String cityLevel, String city, String district, String orderTime, String startTime, String endTime, String orderType);

    Map<String, Long> getsuccessNum(@Param("s") String s);

    Map<String, Long> getOrderNum(String s);
@Select("SELECT SUM(CASE WHEN orders.receiving_time IS NOT NULL AND orders.starting_date IS NOT NULL THEN 1 ELSE 0 END)::decimal / COUNT(*)::decimal AS responseRate \n" +
        "        FROM orders")
    Double getOrderResponseRate();
}
